package com.makenv.service;

import com.makenv.dao.UrlMapper;
import com.makenv.domain.Url;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UrlService {

    @Autowired
    UrlMapper urlMapper;

    public List<Url> showUrlList(int startRow, int num) {

        return urlMapper.showUrlList(startRow, num);
    }

    public int deleteByPrimaryKey(int id) {
        return urlMapper.deleteByPrimaryKey(id);
    }

    public int insert(String link, String description, int priority) {

        Url url = new Url();
        url.setUrl(link);
        url.setDescription(description);
        url.setPriority(priority);
        return urlMapper.insert(url);
    }

    public int updateByPrimaryKey(int id, String link, String description, int priority) {

        Url url = new Url();
        url.setId(id);
        url.setUrl(link);
        url.setDescription(description);
        url.setPriority(priority);
        return urlMapper.updateByPrimaryKey(url);
    }

    public int getUrlsum() {
        return urlMapper.getUrlSum();
    }

}